package com.springcloud.feignclient.web.controller;

import com.alibaba.fastjson.JSON;
import com.codingapi.txlcn.tc.annotation.LcnTransaction;
import com.springcloud.feignclient.client.Client2;
import com.springcloud.feignclient.client.Client3;
import com.springcloud.feignclient.web.entity.User;
import com.springcloud.feignclient.web.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

/**
 * @author liq
 * @Title: UserController
 * @ProjectName lcn-demo
 * @Description: TODO
 * @date 2019-06-0409:08
 */
@RequestMapping("/user")
@RestController
public class UserController {

    @Autowired
    private Client2 client2;

    @Autowired
    private Client3 client3;

    @Autowired
    private UserService userService;


    @GetMapping("/insert")
    @LcnTransaction
    public String update(User user){
        String res ="success";
        Map map = (Map) JSON.parse(JSON.toJSONString(user));
        client2.getMethod("/user/insert",map);
        client3.getMethod("/user/insert",map);
        userService.insert(user);

        String s = null;
        s.length();
        return res;
    }
}
